//package com.example.JcGQS.util;
//
//
//import com.github.rholder.retry.*;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//
//import java.util.Objects;
//import java.util.concurrent.TimeUnit;
//
//@Slf4j
//@Component
//public class Reatry {
//
//
//
//    private static Reatry reatry = null;
//
//    public static Reatry getInstance() {
//        if (reatry == null) {
//            reatry = new Reatry();
//        }
//        return reatry;
//    }
//
//
//    /**
//     * @return
//     */
//    public Retryer<Boolean> retry() {
//        return RetryerBuilder.<Boolean>newBuilder()
//                .retryIfResult(result -> Objects.equals(result, Boolean.FALSE))
//                .retryIfExceptionOfType(PLCException.class)
//                //.withRetryListener(new PlcRetryListener())
//                .retryIfRuntimeException()
//                .withBlockStrategy(BlockStrategies.threadSleepStrategy())
//                .withWaitStrategy(WaitStrategies.fixedWait(3, TimeUnit.SECONDS))
//                .withStopStrategy(StopStrategies.stopAfterAttempt(60))
//                .build();
//    }
//
//
//
//    public Retryer<Boolean> retry(long period) {
//        return RetryerBuilder.<Boolean>newBuilder()
//                .retryIfResult(result -> Objects.equals(result, Boolean.FALSE))
//                .retryIfExceptionOfType(PLCException.class)
//                //.withRetryListener(new PlcRetryListener())
//                .retryIfRuntimeException()
//                .withBlockStrategy(BlockStrategies.threadSleepStrategy())
//                .withWaitStrategy(WaitStrategies.fixedWait(period, TimeUnit.SECONDS))
////                .withStopStrategy(StopStrategies.stopAfterAttempt(90))
//                .build();
//    }
//
//    public Retryer<Boolean> retry(long period, TimeUnit timeUnit) {
//        return RetryerBuilder.<Boolean>newBuilder()
//                .retryIfResult(result -> Objects.equals(result, Boolean.FALSE))
//                .retryIfExceptionOfType(PLCException.class)
//                //.withRetryListener(new PlcRetryListener())
//                .retryIfRuntimeException()
//                .withBlockStrategy(BlockStrategies.threadSleepStrategy())
//                .withWaitStrategy(WaitStrategies.fixedWait(period, timeUnit))
//                .withStopStrategy(StopStrategies.stopAfterAttempt(90))
//                .build();
//    }
//
//    public Retryer<Boolean> retry(long period, int count) {
//        return RetryerBuilder.<Boolean>newBuilder()
//                .retryIfResult(result -> Objects.equals(result, Boolean.FALSE))
//                .retryIfExceptionOfType(PLCException.class)
//                //.withRetryListener(new PlcRetryListener())
//                .retryIfRuntimeException()
//                .withBlockStrategy(BlockStrategies.threadSleepStrategy())//阻塞策略
//                .withWaitStrategy(WaitStrategies.fixedWait(period, TimeUnit.SECONDS))//等待策略
//                .withStopStrategy(StopStrategies.stopAfterAttempt(count))//停止策略
//                .build();
//    }
//
//
//}
